import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CorporateVO, CorporateForm, CorporateQuery } from '@/api/provider/corporate/types';

/**
 * 查询供应商公司信息列表
 * @param query
 * @returns {*}
 */

export const listCorporate = (query?: CorporateQuery): AxiosPromise<CorporateVO[]> => {
  return request({
    url: '/provider/corporate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询所有供应商公司信息列表
 * @returns {*}
 */

export const listAllCorporate = (): AxiosPromise<CorporateVO[]> => {
  return request({
    url: '/provider/corporate/list',
    method: 'get'
  });
};

/**
 * 查询供应商公司信息详细
 * @param id
 */
export const getCorporate = (id: string | number): AxiosPromise<CorporateVO> => {
  return request({
    url: '/provider/corporate/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商公司信息
 * @param data
 */
export const addCorporate = (data: CorporateForm) => {
  return request({
    url: '/provider/corporate',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商公司信息
 * @param data
 */
export const updateCorporate = (data: CorporateForm) => {
  return request({
    url: '/provider/corporate',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商公司信息
 * @param id
 */
export const delCorporate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/provider/corporate/' + id,
    method: 'delete'
  });
};
